<?php
class com_modmanagerIndexController extends Zendvn_Controller_Component{
	public function init(){
		$this->title['string'] = $this->view->translate("module manager");
		$this->title['iconSfx'] 			= 'module';
		require 'models/modules.php';
		$this->mainTable =  new com_modmanagerModelModules();
		
	}
	public function IndexActivity(){
		$this->title['string'] 				.= ' :: '.$this->view->translate("module");
		$this->view->title 	= $this->title;
		
		$this->request['paginator']				= $this->loadConfig(COMPONENTS_PATH.DS.'admin'.DS.'admin.ini','adminDefaultPaginator');
		$this->request['paginator']['page'] 	= (isset($this->request['page'])) ? $this->request['page'] : 1;
		
		
		$this->view->items = $this->mainTable->listItems($this->request,'listItemsNull');
		$this->view->adminListColums =  $this->mainTable->getAdminListColums();
		
		$this->view->paginator = Zendvn_Paginator::create($this->request['paginator'], $this->mainTable->countItems($this->request,'countItemsNull'));
	}
	public function EditActivity(){
		if (!isset($this->request['cid'])) $this->ctrl->_redirect($this->mainActivity);
		//pre data
		//load possition form template
		$config = new Zendvn_Config($this->templatePath.DS.'templateDetail.ini');
		$preData['modulePosition'] = $config->getConfig('extension','positions');
		//load module detail
		$config = new Zendvn_Config(dirname($this->component['path']).DS.'configs'.DS.$this->component['control'].DS.'form.ini');
		$path = explode("|", $config ->getConfig('element','list'));
		$this->view->items = $this->mainTable->getItem($this->request,"getItemNull",$path);
		
		$this->view->preData = $preData;
	}
	public function AjaxOrderFieldActivity(){
		if (isset($this->request['position'])){
			$this->view->items = $this->mainTable->listItems($this->request,'listItemsByPossitonPulished');
		}
	}
	public function AddActivity(){
	}
	public function DeleteActivity(){
		$this->renderView = false;
	}
	public function StatusActivity(){
		$this->renderView = false;
	}
	
}